<div ms-controller="userList" class="col-md-9">
    <h1>用户管理</h1>

    <div class="right">
        <form class="form-inline" onsubmit="return false;">
            <div class="form-group-sm">
                <label>搜索</label>
                <input name="keyword" class="form-control" placeholder="请输入关键词" ms-duplex="keyword">
                <input type="submit" value="搜索" class="btn btn-primary" ms-click="search()">
            </div>
        </form>
        <br>
    </div>
    <table class="table table-striped">
        <tr>
            <th>ID</th>
            <th>用户名</th>
            <th>注册时间</th>
            <th>真实姓名</th>
            <th>电子邮箱</th>
            <th>用户类型</th>
            <th>管理</th>
        </tr>
        <tr ms-repeat="userList">
            <td>{{ el.id }}</td>
            <td>{{ el.username }}</td>
            <td>{{ el.create_time|date("yyyy-MM-dd HH:mm:ss")}}</td>
            <td>{{ el.real_name }}</td>
            <td>{{ el.email }}</td>
            <td>{{ userType[el.admin_type]}}</td>
            <td>
                <button class="btn-sm btn-info" ms-click="editUser(el)">编辑</button>
                <a class="btn btn-primary" ms-attr-href="'/submissions/?user_id='+el.id" target="_blank">提交</a>
            </td>
        </tr>
    </table>
    <div class="form-group">
        <label>仅显示管理员 <input ms-duplex-checked="showAdminOnly" type="checkbox"/></label>
    </div>
    <div class="text-right">
        <ms:pager $id="userPager" config="pager"></ms:pager>
    </div>
    <div ms-visible="isEditing">
        <h3>修改用户信息</h3>

        <form id="edit-user-form">
            <div class="row">
                <div class="form-group col-md-4"><label>ID</label>
                    <input name="id" type="number" class="form-control" readonly ms-duplex="userId">
                </div>
                <div class="form-group col-md-4"><label>用户名</label>
                    <input type="text" class="form-control" ms-duplex="username"
                           data-minlength="3" data-minlength-error="用户名不得少于3位" required>
                    <div class="help-block with-errors"></div>
                </div>
                <div class="form-group col-md-4"><label>真实姓名</label>
                    <input name="real_name" type="text" class="form-control" ms-duplex="realName"
                           data-error="请填写真实姓名" maxlength="30" required>
                    <div class="help-block with-errors"></div>
                </div>
            </div>
            <div class="row">
                <div class="form-group col-md-4"><label>新密码（留空则保留原密码）</label>
                    <input name="password" type="password" class="form-control"
                           autocomplete="off" ms-duplex="password"
                           placeholder="此项留空则保留原密码" data-minlength="6" data-minlength-error="密码不得少于6位">
                    <div class="help-block with-errors"></div>
                </div>
                <div class="form-group col-md-4"><label>电子邮箱</label>
                    <input type="email" class="form-control" ms-duplex="email"
                           data-error="请填写邮箱地址(并保证是正确的邮箱格式)" required>
                    <div class="help-block with-errors"></div>
                </div>
                <div class="form-group col-md-4"><label>用户类型</label>
                    <select name="admin_type" class="form-control" ms-duplex="adminType">
                        <option ms-repeat="userType" ms-attr-value="$index">{{ el }}</option>
                    </select>
                </div>
            </div>
            <div class="row">
                <div class="form-group col-md-3">
                    <label>是否开放API功能</label>
                    <input name="openapi" type="checkbox" class="form-control" ms-duplex-checked="openAPI">
                </div>
                <div class="form-group col-md-3">
                    <label>两步验证</label>
                    <input name="tfa_auth" type="checkbox" class="form-control" ms-duplex-checked="tfa_auth">
                </div>
                <div class="form-group col-md-3">
                    <label>是否禁用用户</label>
                    <input name="is_forbidden" type="checkbox" class="form-control" ms-duplex-checked="is_forbidden">
				</div>
            </div>
            <div class="form-group">
                <button type="submit" class="btn btn-success">保存修改</button>
            </div>
        </form>
    </div>
</div>
<script src="/static/js/app/admin/user/userList.js"></script>
